﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="HighlightingSettingsManagerOptionsForm.cs" company="Roman '4ux-nbIx' Novitsky">
//   Copyright (c) Roman '4ux-nbIx' Novitsky 2009
// </copyright>
// <summary>
//   Describes and manipulates the highlighting settings manager options form.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace SettingsManager.ComponentSettingsManagers
{
  #region Namespace Imports

  using System;
  using System.Windows.Forms;

  using JetBrains.Annotations;

  #endregion


  /// <summary>
  /// Describes and manipulates the highlighting settings manager options form.
  /// </summary>
  public sealed partial class HighlightingSettingsManagerOptionsForm : SettingsManagerOptionsForm
  {
    #region Constants and Fields

    private HighlightingSettingsManagerOptions _options;

    #endregion


    #region Constructors and Destructors

    /// <summary>
    /// Initializes a new instance of the <see cref="HighlightingSettingsManagerOptionsForm"/> class.
    /// </summary>
    public HighlightingSettingsManagerOptionsForm()
    {
      InitializeComponent();
    }

    #endregion


    #region Properties

    /// <summary>
    /// Gets or sets the options.
    /// </summary>
    /// <value>
    /// The options.
    /// </value>
    public override object Options
    {
      get
      {
        return _options;
      }

      set
      {
        _options = value as HighlightingSettingsManagerOptions;

        UpdateControls();
      }
    }

    #endregion


    #region Methods

    private void OnOkButtonClick([NotNull] object sender, [NotNull] EventArgs e)
    {
      _options = new HighlightingSettingsManagerOptions
                   {
                     ForceEnableCodeAnalysis = _forceEnableCodeAnalysisCheckBox.Checked, 
                     ForceEnableSolutionWideAnalysis = _forceEnableSolutionWideAnalysisCheckBox.Checked
                   };

      Options = _options;

      DialogResult = DialogResult.OK;
    }


    private void UpdateControls()
    {
      if (_options != null)
      {
        _forceEnableCodeAnalysisCheckBox.Checked = _options.ForceEnableCodeAnalysis;
        _forceEnableSolutionWideAnalysisCheckBox.Checked = _options.ForceEnableSolutionWideAnalysis;
      }
      else
      {
        _forceEnableCodeAnalysisCheckBox.Checked = true;
        _forceEnableSolutionWideAnalysisCheckBox.Checked = false;
      }
    }

    #endregion
  }
}